package com.booksystem.campuslibrarymanagementsystem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.booksystem.campuslibrarymanagementsystem.commen.request.userquest.BookBorrowrequst.Approval;
import com.booksystem.campuslibrarymanagementsystem.commen.result.userresuilt.ApprovalList;
import com.booksystem.campuslibrarymanagementsystem.entity.BooksTable;
import com.booksystem.campuslibrarymanagementsystem.entity.BorrowApprovalsTable;
import com.booksystem.campuslibrarymanagementsystem.mapper.BorrowApprovalsTableMapper;
import com.booksystem.campuslibrarymanagementsystem.service.BorrowApprovalsTableService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;

@Service
public class BorrowApprovalsTableServiceImpl extends ServiceImpl<BorrowApprovalsTableMapper, BorrowApprovalsTable> implements BorrowApprovalsTableService {
    @Autowired
    BorrowApprovalsTableMapper borrowApprovalsTableMapper;

    @Override
    public Approval queryid(int bookid) {
        return borrowApprovalsTableMapper.queryid(bookid);
    }

    @Override
    public int updatebook(Approval book) {
        return borrowApprovalsTableMapper.updatebook(book);
    }

    @Override
    public List<BorrowApprovalsTable> existsByAccountAndBookidi(String account, int bookid) {
        return borrowApprovalsTableMapper.existsByAccountAndBookidi(account, bookid);
    }

    @Override
    public boolean save(BorrowApprovalsTable hh) {
        return borrowApprovalsTableMapper.save(hh);
    }

    @Override
    public List<ApprovalList> returnliststatus(String account, String approvalstate) {
        return borrowApprovalsTableMapper.returnliststatus(account, approvalstate);
    }

    @Override
    public List<ApprovalList> selectByaccount(@Param("account") String account) {
        return borrowApprovalsTableMapper.selectByaccount(account);
    }

    @Override
    public int deleteByAccountAndBookid(@Param("account") String account, @Param("recordid") int recordid) {
        return borrowApprovalsTableMapper.deleteByAccountAndBookid(account, recordid);
    }

    @Override
    public BooksTable aaa(int bookid) {
        return borrowApprovalsTableMapper.aaa(bookid);
    }

    @Override
    public void unapproval(String account, LocalDate approvalTime, String bookid, String Approvalstate) {
        borrowApprovalsTableMapper.unapproval(account,approvalTime,bookid,Approvalstate);
    }

    @Override
    public void onapproval(String account, LocalDate approvalTime, String bookid, String Approvalstate) {
        borrowApprovalsTableMapper.onapproval(account,approvalTime,bookid,Approvalstate);
    }

    @Override
    public List<BorrowApprovalsTable> queryByAccount(String account) {
        return borrowApprovalsTableMapper.queryByAccount(account);
    }

    @Override
    public String querytime(int bookid , String account){
        return borrowApprovalsTableMapper.querytime(bookid,account);
    }

    @Override
    public List<BorrowApprovalsTable> querydislist(String approvalstate) {
        return borrowApprovalsTableMapper.querydislist(approvalstate);
    }

    @Override
    public List<BorrowApprovalsTable> getByApprovalState(String approvalstate) {
            LambdaQueryWrapper<BorrowApprovalsTable> wrapper = new LambdaQueryWrapper<>();
            wrapper.eq(BorrowApprovalsTable::getApprovalstate, approvalstate);
            return super.list(wrapper);
    }


}
